exception handler
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | level |
log level: info | warning | error |
||
character(len=*), | intent(in) | :: | process |
process which threw esception |
||
character(len=*), | intent(in) | :: | comment |
comment on exception |
||
integer(kind=short), | intent(in), | optional | :: | code |
error code to return |
|
character(len=*), | intent(in), | optional | :: | argument |
optional argument |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=short), | public | :: | logStatus |
SUBROUTINE Catch & ! (level, process, comment, code, argument) IMPLICIT NONE ! Subroutine arguments ! Scalar arguments with intent(in): CHARACTER (LEN = *), INTENT(in) :: level !! log level: info | warning | error CHARACTER (LEN = *), INTENT(in) :: process !! process which threw esception CHARACTER (LEN = *), INTENT(in) :: comment !! comment on exception INTEGER (KIND = short), OPTIONAL, INTENT(in) :: code !! error code to return CHARACTER (LEN = *), OPTIONAL, INTENT(in) :: argument !! optional argument ! Local Scalars: INTEGER (KIND = short) :: logStatus !------------end of declaration------------------------------------------------ !------------------------------------------------------------------------------ ![1.0] Define actual log level status !------------------------------------------------------------------------------ SELECT CASE ( level ) CASE ("error") logStatus = 1 CASE ("warning") logStatus = 2 CASE ("info") logStatus = 3 END SELECT !------------------------------------------------------------------------------ ![2.0] Put an entry on log file !------------------------------------------------------------------------------ IF (logToFile) THEN IF (logStatus <= logLevel) THEN IF ( PRESENT(argument) ) THEN CALL LogMsg(logUnit, level, process, comment, argument = argument) ELSE CALL LogMsg(logUnit, level, process, comment) ENDIF ENDIF ENDIF !------------------------------------------------------------------------------ ![3.0] Display on screen !------------------------------------------------------------------------------ IF (logToScreen) THEN IF (logStatus <= logLevel) THEN IF (verbose) THEN IF ( PRESENT(argument) ) THEN CALL LogMsg(stdOut, level, process, comment, argument = argument) ELSE CALL LogMsg(stdOut, level, process, comment) ENDIF ENDIF END IF END IF !------------------------------------------------------------------------------ ![4.0] Decide program termination !------------------------------------------------------------------------------ IF (level == 'error' ) THEN IF ( PRESENT (code) ) THEN IF (logToFile) THEN CALL LogStop () ENDIF !PAUSE CALL EXIT(code) ELSE IF (logToFile) THEN CALL LogStop () ENDIF !PAUSE CALL EXIT() ENDIF ENDIF END SUBROUTINE Catch